<!-- 病例专栏 -->
<template>
    <div class="page-box h100 display-flex czbj">
        <p class="title-label mb10" v-if="!pup">
          先见E术家丨病例专栏
          <!-- :czFun="czFun" -->
        </p>
        <div>
            <dxtable :headBtn="headBtn" :dataJson="dataJson" :formJson="formJson" :portUrl="portUrl" :qx="qx" imgkuTitle="病例专栏" ref="databale"
                :hidebj="hidebj" @bjfun="bjfun" ></dxtable>
        </div>

        <n-modal v-model:show="xzcxwerr" preset="card" class="Stock-diagnosis">
  <template #header>
  <div>评论管理</div>
  </template>
  <div>
  <plgl type="2" :plid='plid'></plgl>
  </div>
  <template #action>
  <div class="tr">
  <n-button @click="xzcxwerr=false"> 关闭 </n-button>
  </div>
  </template>
  </n-modal>
    </div>
</template>
<script lang='ts' setup>
import dxtable from "../../components/util/dxtable.vue";
import sort from "../../components/util/sort.vue";
import { dxget, dxpost, qurl, hf, transferTimeYMD } from "../../util/index";
import { h, ref, reactive } from "vue";
import {zdian} from "./public"
import {NButton} from "naive-ui"
import dz from "./dz.vue";
import plgl from "./plgl.vue";
const props = defineProps({ 
    pup: { type: String },
    zfleix:{ type: String },
});
const qx = ref({})
const showModal = ref()
const videourl = ref()
let headBtn = ref([]);

const xzcxwerr= ref(false)
const plid = ref()


const zdList = ref()
const databale = ref();
const typeli = ref([])
const hidebj = ref(false)
const erlbopt = ref()
const lkser = ref([])
const initeer = () => {
    databale.value.initDataExpose();
};
let portUrl = "xjyx/xjyxCaseColumn";
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
    {
        title: "名称",
        key: "title",
        search: true, // 是否在搜索栏展示
        ellipsis: {
            tooltip: true
        }
    },
    {
        title: "关键词",
        key: "keyword",
        search: true, // 是否在搜索栏展示
        ellipsis: {
            tooltip: true
        }
    },
    {
        title: "链接",
        key: "url",
        width: 100,
        render(row) {
            return h("span", {
                class: "ls sz", onClick: () => {
                    open(row.url)
                }
            }, "浏览")
        }
    },

    {
        title: "类别",
        key: "sort",
        search: true, // 是否在搜索栏展示
        type: "select",
        options:zdian,
        render(row) {
            console.log(zdian);
            row.sort =  row.sort.split(",")
            const kjdsr = []
            lkser.value.map(a=>{
              row.sort.map(b=>{
                if(a.value==b){
                  kjdsr.push(a.label)
                }
              })
             
            })
            return kjdsr.join(",")
            // try {
            //     return lkser.value.filter(a => a.value == row.sort)[0].label
            // } catch (e) {
            //     return '--'
            // }
        }
    }, 
    // {
    //     title: "二级分类",
    //     key: "ersort",
    //     width: 100,
    //     type: "select",
    //     options: [],
    //     render(row) {
    //         try {
    //             const kjerr =  zdian.filter(a => a.value == row.sort)[0].junior
    //             return kjerr.filter(a => a.value == row.ersort)[0].label
    //         } catch (e) {
    //             return row.ersort
    //         }
    //     }
    // },



//     { 
//     title: "点赞基数",
//     key: "dianzan",
//     width: 100,
//     render(row) {
//       return h(dz, {
//         row,
//         api:portUrl,
//         keyName:"dianzan",
//         onCallBack: () => {
//           initeer();
//         },
//       })
      
//     }
//   }, {
//     title: "收藏基数",
//     key: "scjs",
//     width: 100,
//     render(row) {
//       return h(dz, {
//         row,
//         api:portUrl,
//         keyName:"scjs",
//         onCallBack: () => {
//           initeer();
//         },
//       })
      
//     }
//   },


    {
        title: "排序",
        width: 100,
        render(row) {
            row.databaseName = "xjyxCaseColumn";
            return h(sort, {
                row,
                onCallBack: () => {
                    initeer();
                },
            });
        },
    },
    {
        title: "添加时间",
        key: "addTime",
        width: "140",
        type: "daterange",
    },
]);


let formJson = reactive([

    {
        title: "活动名称",
        key: "title",
        type: "input",
        span: 24,
        required: true,
    },
    {
        title: "关键词",
        key: "keyword",
        type: "input",
        span: 24,
    },
    {
        title: "活动链接",
        key: "url",
        span: 24,
        type: "input",
        required: true,
    }, {
        title: "活动封面",
        key: "cover",
        type: "img",
        required: true,
        span: 24, 
    }, {
        title: "类别",
        key: "sort",
        // required: true,
        type: "select",
        options: zdian,
        span: 24, 
        multiple:true,
        // callBack(data,m){
        //     databale.value.setmodel('ersort','')
        //     formJson[5].options= m.junior
        // }
    }, 
    // {
    //     title: "二级类别",
    //     key: "ersort",
    //     required: true,
    //     type: "select",
    //     options: []
    // },
     {
        title: "添加时间",
        key: "addTime",
        val: transferTimeYMD(new Date().getTime()),
        type: "date"
    },
])
const bjfun = (data)=>{
    try{
        formJson[5].options= zdian.filter((a)=>a.value==data.sort)[0].junior
    }catch(e){
        
    }
}

qx.value = {
    DeletePermissionID: "xjyxCaseColumndel", //删除
    EditPermissionIdentifier: "xjyxCaseColumnbj", // 编辑
    NewPermissionIdentifier: "xjyxCaseColumnxz", // 新建
    ViewPermissionID: "xjyxCaseColumnck", // 查看
};



if(props.pup==2){
 dataJson = [{
        title: "名称",
        key: "title",
        search: true, // 是否在搜索栏展示
        ellipsis: {
            tooltip: true
        }
    },];
hidebj.value = true

qx.value = {
  DeletePermissionID: "23456", //删除
  EditPermissionIdentifier: "", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "", // 查看
}
headBtn.value = [
  {
    name: "确认添加",
    jy: true,
    type: "info",
    clickFun: async (calld) => {
      if(calld.length<=0){
       window.$message.error('请在列表中勾选数据')
        return
      }
      const {data} =  await dxpost('xjyx/api/addblisd', { ids:calld.join(','),zfleix:props.zfleix})
     
      emit('callBack')
      },
  },
]
}




const getcasetype = async () => {
    const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xjyxblzlfl' })

    formJson[4].options = data
    lkser.value = data
    dataJson[3].options = [
      {
        label:"全部",
        value:""
      },
      ...data
    ]

    // ishjwoer.value = true
}
getcasetype()

const czFun = {
    fun: (row, loading) => {
        return [
            h(
                NButton,
                {
                    type: "info",
                    quaternary: true,
                    onClick: async (e) => {
                      xzcxwerr.value = true
                      plid.value = row.id
                    },
                },
                "评论管理"
            )

        ];
    },
};
</script>
  
  
  